const path=require('path')
const HtmlWebpackplugn=require('html-webpack-plugin')
const CleanWebpackplugn=require('clean-webpack-plugin')
const webpack=require('webpack')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports={
    entry:{
        app:'./src/index.js',
        // print:'./src/print.js'
    },
    // devtool:'inline-source-map',
    devServer:{
        contentBase:'./dist',
        hot:true
    },
    plugins:[
        new CleanWebpackplugn(['dist']),
        new HtmlWebpackplugn({
            title: '牛逼啊'
        }),
        new webpack.NamedModulesPlugin(),
        new webpack.HotModuleReplacementPlugin(),
        new UglifyJSPlugin()
    ],
    output:{
        filename:'[name].main.js',
        path:path.resolve(__dirname,'dist'),
        publicPath:'/'
    },
    module:{
        rules:[
            {
                test:/\.css$/,
                use:[
                    'style-loader',
                    'css-loader'
                ]
            },
            {
                test:/\.(png|svg|jpg|gif)$/,
                use:[
                    'file-loader'
                ]
            },
            {
                test: /\.(woff|woff2|eot|ttf|otf)$/,
                use: [
                    'file-loader'
                ]
            },
            {
                test: /\.(csv|tsv)$/,
                use: [
                     'csv-loader'
                ]
            },
            {
                test: /\.xml$/,
                use: [
                    'xml-loader'
                ]
            }
        ]
    }
}